<html>
<head><meta charset="utf-8"><title>stdarch increases compile times · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html">stdarch increases compile times</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218298021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218298021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218298021">(Nov 30 2020 at 15:03)</a>:</h4>
<p>Have been there any follow up on +40% core build time regression after changes to stdarch? The primary cause is the fact that it implements intrinsics that require const arguments by instantiating them for all possible values, which unsurprisingly lead to exorbitant compile times (locally for me stdarch alone accounts for 30% of build time of the whole standard library).</p>



<a name="218299320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299320">(Nov 30 2020 at 15:13)</a>:</h4>
<p>No, I don't think it is fixable</p>



<a name="218299447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299447">(Nov 30 2020 at 15:14)</a>:</h4>
<p>I am surprised to hear we are doing that though, would expect const generics or <code>#[rustc_required_const]</code> to be used</p>



<a name="218299468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299468">(Nov 30 2020 at 15:14)</a>:</h4>
<p>(or const_param? whatever the attribute is)</p>



<a name="218299546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299546">(Nov 30 2020 at 15:15)</a>:</h4>
<p>that said, I will make a mention of it in the portable SIMD stream</p>



<a name="218299621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299621">(Nov 30 2020 at 15:15)</a>:</h4>
<p>It is <code>#[rustc_arg_required_const]</code>. This is the exact reason the match exists. The <code>simd_insert</code> and <code>simd_extract</code> intrinsics have this argument applied, so <code>constify_*!</code> has to be used.</p>



<a name="218299738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299738">(Nov 30 2020 at 15:16)</a>:</h4>
<p>Why can we not propagate the required_const up?</p>



<a name="218299885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299885">(Nov 30 2020 at 15:17)</a>:</h4>
<p>oh yeah these matches look pretty bad</p>



<a name="218299903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218299903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218299903">(Nov 30 2020 at 15:17)</a>:</h4>
<p>The wrapper functions do have it too, but to make it work with cg_clif, they would need to be inlined <strong>and</strong> const propagated for the const arguments to be const at codegen time.</p>



<a name="218300118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300118">(Nov 30 2020 at 15:19)</a>:</h4>
<p>cg_llvm can technically get away with not using the match as LLVM handles non-const indexes for simd insertion and extraction. cg_clif however requires them to be constant when doing codegen.</p>



<a name="218300125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300125">(Nov 30 2020 at 15:19)</a>:</h4>
<p>Can we not make the call to the intrinsic directly from the first function exposed to user code? I guess I can just grep</p>



<a name="218300232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300232">(Nov 30 2020 at 15:19)</a>:</h4>
<p>That is what we do. However we for example need to mask the const argument, as we don't have <code>i4</code> and similar small integer types.</p>



<a name="218300336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300336">(Nov 30 2020 at 15:20)</a>:</h4>
<p>In addition mir inlining is not yet enabled by default, so that won't work with cg_clif either.</p>



<a name="218300368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300368">(Nov 30 2020 at 15:20)</a>:</h4>
<p>I guess maybe I'm missing something</p>



<a name="218300428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300428">(Nov 30 2020 at 15:20)</a>:</h4>
<p>but I would expect regular const prop to be sufficient to deal with <a href="https://github.com/rust-lang/stdarch/blob/777efaf5644706b36706a7a5c51edb63835e05ca/crates/core_arch/src/x86/avx.rs#L412-L417">https://github.com/rust-lang/stdarch/blob/777efaf5644706b36706a7a5c51edb63835e05ca/crates/core_arch/src/x86/avx.rs#L412-L417</a> for example without needing a constify! call</p>



<a name="218300504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300504">(Nov 30 2020 at 15:21)</a>:</h4>
<p>i.e., if that was written <code>roundpd256(a, b as i8)</code> I would expect that to be fine</p>



<a name="218300519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300519">(Nov 30 2020 at 15:21)</a>:</h4>
<p>There is no inlining at MIR level, so const prop only sees an unknown function parameter.</p>



<a name="218300542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300542">(Nov 30 2020 at 15:21)</a>:</h4>
<p>it's not a function param though?</p>



<a name="218300548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300548">(Nov 30 2020 at 15:21)</a>:</h4>
<p>it's a const param?</p>



<a name="218300572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300572">(Nov 30 2020 at 15:21)</a>:</h4>
<p>Or do we not treat it as such?</p>



<a name="218300579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300579">(Nov 30 2020 at 15:21)</a>:</h4>
<p>At MIR level it is a regular function param.</p>



<a name="218300628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300628">(Nov 30 2020 at 15:22)</a>:</h4>
<p>That is ... surprising to me</p>



<a name="218300664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300664">(Nov 30 2020 at 15:22)</a>:</h4>
<p>I would expect rustc_args_required_const to desugar to a const generic</p>



<a name="218300678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300678">(Nov 30 2020 at 15:22)</a>:</h4>
<p>There has been talk about making it desugar to a const generic, but that hasn't been done.</p>



<a name="218300680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300680">(Nov 30 2020 at 15:22)</a>:</h4>
<p>is there a reason it doesn't?</p>



<a name="218300710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300710">(Nov 30 2020 at 15:22)</a>:</h4>
<p>(do we have a tracking issue?)</p>



<a name="218300776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300776">(Nov 30 2020 at 15:23)</a>:</h4>
<p>I am pretty sure <code>#[rustc_args_required_const]</code> existed before const generics.</p>



<a name="218300895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300895">(Nov 30 2020 at 15:24)</a>:</h4>
<p>That sounds right.</p>



<a name="218300991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218300991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218300991">(Nov 30 2020 at 15:24)</a>:</h4>
<p><code>#[rustc_*]</code> is for attributes that will never be stable. I couldn't find a tracking issue.</p>



<a name="218301026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218301026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218301026">(Nov 30 2020 at 15:25)</a>:</h4>
<p>No, I mean, an issue for the const generic promotion</p>



<a name="218301218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218301218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218301218">(Nov 30 2020 at 15:26)</a>:</h4>
<p>I found <a href="https://github.com/rust-lang/rust/issues/70271">#70271</a> about limiting <code>#[rustc_args_required_const]</code> to intrinsics only.</p>



<a name="218301328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218301328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218301328">(Nov 30 2020 at 15:27)</a>:</h4>
<p>I didn't find an issue about desugaring to const generics.</p>



<a name="218301532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218301532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218301532">(Nov 30 2020 at 15:28)</a>:</h4>
<p>ok</p>



<a name="218996315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996315">(Dec 06 2020 at 17:40)</a>:</h4>
<p>Implementing <code>#[rustc_required_const]</code> through guaranteed inlining and const propagation of the argument looks quite plausible. Though it conceptually conflicts with <code>#[target_feature]</code>.</p>



<a name="218996400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996400">(Dec 06 2020 at 17:42)</a>:</h4>
<p>You aren't really supposed to call those intrinsics without using the corresponding <code>#[target_feature]</code> on the current function.</p>



<a name="218996456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996456">(Dec 06 2020 at 17:44)</a>:</h4>
<p>You can have a call that is not invoked at runtime, but target-feature can be only attached to functions so after inlining boundary between the two is lost.</p>



<a name="218996523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996523">(Dec 06 2020 at 17:46)</a>:</h4>
<p>Not inlining has enough overhead that calling them while preventing inlining is slower than simply emulating them in your own code. <code>extern "Rust"</code> functions always force vector arguments to the stack.</p>



<a name="218996606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996606">(Dec 06 2020 at 17:49)</a>:</h4>
<p>I mean simply that the information about target-feature is lost and never reaches LLVM if inlining were to be done at MIR (not inlining them at all would be silly).</p>



<a name="218996660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996660">(Dec 06 2020 at 17:50)</a>:</h4>
<p>or alternatively target-feature leaks to the caller</p>



<a name="218996662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996662">(Dec 06 2020 at 17:50)</a>:</h4>
<p>If the target-feature doesn't match, no inlining is ever performed by LLVM.</p>



<a name="218996674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996674">(Dec 06 2020 at 17:51)</a>:</h4>
<p>Forcing inlining leaks the target-features to the callee not the other way around.</p>



<a name="218996729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996729">(Dec 06 2020 at 17:52)</a>:</h4>
<p>well, currently target-feature is attached to the Rust wrapper not intrinsic itself, so if those wrappers were to be inlined at MIR level, the information would be lost</p>



<a name="218996746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996746">(Dec 06 2020 at 17:53)</a>:</h4>
<p>Yeah, the target-feature of the caller is used instead of the wrapper. This is not a bad thing IMO as you would get a big overhead if the target-feature doesn't match and inlining isn't forced.</p>



<a name="218996865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996865">(Dec 06 2020 at 17:57)</a>:</h4>
<p>The inlining is already implemented, so it would be matter of changing the conditions under which it happens. Adding to that const-propagation of the const argument through temporaries doesn't seem particularly challenging.</p>



<a name="218996995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218996995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218996995">(Dec 06 2020 at 18:00)</a>:</h4>
<p>Of course implementing this would result in further proliferation of <code>#[rustc_required_const]</code> on non-intrinsics, which seems dubious in the first place.</p>



<a name="218997167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218997167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218997167">(Dec 06 2020 at 18:05)</a>:</h4>
<p>There could be a separate <code>#[specialize(0)]</code> to specialize a function on the first argument without requiring the first argument to be const and without forcing it to be inlined. The atomic type methods could especially use this to specialize on the memory ordering even in debug mode and with cg_clif.</p>
<p>The platform intrinsics could then get something like <code>#[inline] #[specialize(2)] #[rustc_arg_required_const]</code>.</p>



<a name="218997370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/218997370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#218997370">(Dec 06 2020 at 18:10)</a>:</h4>
<p>It would also be nice to have a <code>#[inline(force)]</code> that forces MIR inlining and gives an error when there is an inlining cycle.</p>



<a name="219058833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/219058833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#219058833">(Dec 07 2020 at 09:46)</a>:</h4>
<p>Losing a target-feature is actually more serious, since without it in some cases LLVM is not able to do the codegen</p>



<a name="219059074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/stdarch%20increases%20compile%20times/near/219059074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/stdarch.20increases.20compile.20times.html#219059074">(Dec 07 2020 at 09:49)</a>:</h4>
<p>de-sugaring <code>rustc_required_const</code>  to const generics looks like more viable implementation strategy</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>